home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 213 < prev    next >
Text File  |  1996-08-06  |  4KB  |  83 lines

  1. Newsgroups: comp.lang.c,comp.std.c
  2. Path: blackbush.xlink.net!slsv6bt!slsv6bt!kanze
  3. From: kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763)
  4. Subject: Re: Integral conversion e.t.c. (was: Re: Hungarian notation)
  5. In-Reply-To: seebs@solutions.solon.com's message of 27 Jan 1996 12:22:26 -0600
  6. Message-ID: <KANZE.96Jan29121956@slsvewt.lts.sel.alcatel.de>
  7. Sender: news@lts.sel.alcatel.de
  8. Organization: SEL
  9. References: <30C40F77.53B5@swsbbs.com> <SPENCER.96Jan22113215@zorgon.ERA.COM>
  10.     <KANZE.96Jan26164833@gabi.gabi-soft.fr> <DLtABq.Fzu@mv.mv.com>
  11.     <4edqh2$rvl@solutions.solon.com>
  12. Date: 29 Jan 1996 11:19:56 GMT
  13.  
  14. In article <4edqh2$rvl@solutions.solon.com> seebs@solutions.solon.com
  15. (Peter Seebach) writes:
  16.  
  17. |> In article <DLtABq.Fzu@mv.mv.com>, Michael Furman <ENGR@GSSI.MV.COM> wrote:
  18. |> [Re a rule forbidding extensions.]
  19.     [And in particular, additional forms of main...]
  20.  
  21. |> >My question was: is such rule exists?
  22.  
  23. |> Sort of.
  24.  
  25. |> There are two kinds of things called "legal" C.  One is a strictly
  26. |> conforming program, which must be accepted by, and work on, *any*
  27. |> conforming C compiler.  The other is merely a conforming
  28. |> program, which must be accepted by, and work on, *at least one*
  29. |> conforming compiler.  The latter class is meaningless; FORTRAN is
  30. |> conforming C.  (gcc with g77 compiles it.  Technically, gcc is not
  31. |> quite conforming, but nothing is.)
  32.  
  33. There is more to it than that.  There are many programs (including
  34. most legal fortran programs) for which the compiler is required to
  35. issue a diagnostic (after which, it may go ahead and compile it as
  36. fortran, or cobol, or whatever).
  37.  
  38. In the particular case which you cite, I do *not* believe that gcc
  39. will compile the program without a diagnostic if the program is in a
  40. file called a.c.  More ever, the compiler documentation definitly
  41. states that only programs in files whose names end in .c will be
  42. compiled as C.  (A legal restriction, as far as I can see.)
  43.  
  44. I think the crux of Michael Furman's question lies therein.  Does the
  45. standard require a diagnostic if the function main is not of one of
  46. the two types given?
  47.  
  48. To tell the truth, I'm not sure what the answer is.  The text
  49. concerning main is in the chapter describing the environment.  It
  50. doesn't appear as a semantic restriction or anything.  It simply
  51. states that on start-up, a function called main will be called, and
  52. that the implementation must support the following forms.  It doesn't
  53. seem (to me, at least) to say anything about what other forms it might
  54. support, or what the implementation must do if given a fully other
  55. definition of main.
  56.  
  57. Normally, I would expect (at the very least) a compiler to generate a
  58. warning or an error for a main that it did not support.  In fact,
  59. however, my compiler (gcc) accepts the following definition without
  60. the slightest complaint, although I'd rather not think about what will
  61. happen when I access parameter d:
  62.  
  63.     int main( char a , int b , long c , double d )
  64.  
  65. |> For purposes of the C newsgroups, discussion of what is/isn't legal
  66. |> is generally restricted to strictly conforming C.
  67.  
  68. Yes and no.  In comp.std.c, the discussion is exactly about what is
  69. legal according to the standard.  In comp.lang.c (to which this
  70. article is also cross-posted), the discussion should generally be a
  71. bit more open.
  72.  
  73. Thus, for example, in comp.std.c, a program with a variable named far
  74. is illegal, and that is it.  In comp.lang.c (and I hope in its
  75. moderated variant), I would hope that someone would point out that,
  76. legal or not, it's going to get you into trouble.
  77. --
  78. James Kanze         Tel.: (+33) 88 14 49 00        email: kanze@gabi-soft.fr
  79. GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
  80. Conseils, Θtudes et rΘalisations en logiciel orientΘ objet --
  81.                 -- A la recherche d'une activitΘ dans une region francophone
  82.  
  83.